config_setting(
    name = "darwin",
    values = {"cpu": "darwin"},
)

cc_library(
    name = "version",
    srcs = ["cxx_version.cc"],
    hdrs = ["version.h"],
    linkopts = ["-ldl"],
    visibility = ["//tests/legacy/examples/cgo:__pkg__"],
    # TODO(yugui) Support darwin too and remove this workaround.
    # See also comments in cxx_version.cc.
    deps = select({
        ":darwin": [],
        "//conditions:default": [":c_version_import"],
    }),
)

cc_library(
    name = "c_version_orig",
    srcs = ["c_version.c"],
    hdrs = ["c_version.h"],
)

# Goes through filegroup() to emulate prebuilt .so in srcs of cc_library.
filegroup(
    name = "c_version_so",
    srcs = [":c_version_orig"],
    output_group = "dynamic_library",
)

cc_import(
    name = "c_version_import",
    hdrs = ["c_version.h"],
    shared_library = ":c_version_so",
    tags = ["manual"],
)
